<?php
class PagosController extends AppController
{
	var $name='Pagos';
	var $uses=array('Pago');
	var $helpers = array('Html','Form','Ajax','Javascript');
	var $components=array('RequestHandler');
		
	function beforeFilter()
	{
		if(!$this->Session->read('admin'))
		{
			$this->Session->setFlash('Area Restringida');
			$this->redirect(array('controller'=>'menus','action'=>'index'));
		}
	}
	
	function add()
	{
		if(!empty($this->data))
		{
			$this->Pago->create();
			//if($this->Pago->save($this->data,array('validate'=>'first')))
			if($this->Pago->save($this->data))
			{
				$this->redirect(array('controller'=>'datos','action'=>'index'));
			}
			else
			{
				$this->Session->setFlash('Ha Ocurrido un Error, Intente Nuevamente');
			}
		}
	}
	
	function delete($id=null)
	{
		if(!$id)
		{
			$this->Session->setFlash('Ha Ocurrido un Error, Intente de Nuevo');
			$this->redirect(array('controller'=>'datos','action'=>'index'),null,true);
		}
		if($this->Pago->del($id))
		{
			$this->redirect(array('controller'=>'datos','action'=>'index'),null,true);
		}
	}
}	
?>